<form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
    <div class="layui-card-body">
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">类型</label>
                <div class="layui-input-block">
                    <select name='type' class='layui-select layui-bg-gray' lay-filter="type">
                        <!--{foreach [0=>'运力',1=>'分拣'] as $k=>$v}-->
                        <!--{eq name='k' value='$vo.type|default=0'}-->
                        <option selected value='{$k}'>{$v}</option>
                        <!--{else}-->
                        <option value='{$k}'>{$v}</option>
                        <!--{/eq}-->
                        <!--{/foreach}-->
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">属性</label>
                <div class="layui-input-block">
                    <select name="att" lay-filter="att" id="two_cate" required lay-search></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs4 layui-col-sm4 layui-col-md4 body_id">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">主体</label>
                <div class="layui-input-block">
                    <select name="body_id" lay-filter="body_id" id="three_cate" required lay-search ></select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">结算方式</label>
                <div class="layui-input-block">
                    <select name='payment_way' class='layui-select'>
                        <!--{foreach [0=>'周结',1=>'月结'] as $k=>$v}-->
                        <!--{eq name='k' value='$vo.payment_way|default=1'}-->
                        <option selected value='{$k}'>{$v}</option>
                        <!--{else}-->
                        <option value='{$k}'>{$v}</option>
                        <!--{/eq}-->
                        <!--{/foreach}-->
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">姓名</label>
                <div class="layui-input-block">
                    <input name="name" value='{$vo.name|default=""}' required placeholder="请输入姓名" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">手机</label>
                <div class="layui-input-block">
                    <input type="tel" autocomplete="off" required autofocus name="phone" value='{$vo.phone|default=""}' pattern="^1[3-9][0-9]{9}$" placeholder="请正确输入手机号" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">支付方式</label>
                <div class="layui-input-block">
                    <select name='pay_way' class='layui-select' lay-search>
                        <!--{foreach [0=>'灵活用工',1=>'银行转账',2=>'线下支付'] as $k=>$v}-->
                        <!--{eq name='k' value='$vo.pay_way|default=0'}-->
                        <option selected value='{$k}'>{$v}</option>
                        <!--{else}-->
                        <option value='{$k}'>{$v}</option>
                        <!--{/eq}-->
                        <!--{/foreach}-->
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label label-required">入职时间</label>
                <div class="layui-input-block">
                    <input data-date-input="date" name="in_time" required value='{$vo.in_time|default=""}'
                        placeholder="请输入入职时间" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">离职时间</label>
                <div class="layui-input-block">
                    <input data-date-input="date" name="out_time" value='{$vo.out_time|default=""}'
                        placeholder="请输入离职时间" class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">银行卡号</label>
                <div class="layui-input-block">
                    <input name="bank_number" value='{$vo.bank_number|default=""}' placeholder="请输入银行卡号"
                        class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item">
                <label class="layui-form-label">身份证号</label>
                <div class="layui-input-block">
                    <input name="ID_number" value='{$vo.ID_number|default=""}' placeholder="请输入身份证"
                        class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item car_number">
                <label class="layui-form-label">车牌号</label>
                <div class="layui-input-block">
                    <input name="car_number" value='{$vo.car_number|default=""}' placeholder="请输入车牌号"
                        class="layui-input">
                </div>
            </div>
        </div>
        
        <div class="layui-col-xs6 layui-col-sm6 layui-col-md6">
            <div class="layui-form-item car_type">
                <label class="layui-form-label">车型</label>
                <div class="layui-input-block">
                    <input name="car_type" value='{$vo.car_type|default=""}' placeholder="请输入车型"
                        class="layui-input">
                </div>
            </div>
        </div>
    </div>
    
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>

    <script>
    window.form.render();
    $(function(){
        var value = $('select[name="type"]').val();
        change_type(value);
        var att = $('select[name="att"]').val();
        change_att(att);
    })
    form.on('select(type)', function(data){
        change_type(data.value);
    });
    function change_type(value){
        $("#two_cate").empty();
        if(value == 0){
            var info = {0:'车队',1:'个人'};
        }else{
            var info = {2:'劳务',3:'自招'};
        }
        $.each(info, function(index,item){
            if(index == '{$vo.att|default=0}'){
                $("#two_cate").append(new Option(item, index, true, true));
            }else{
                $("#two_cate").append(new Option(item,index));
            }
        });
        var att = $('select[name="att"]').val();
        change_att(att);
        layui.form.render("select");
    }
    form.on('select(att)', function(data){
        change_att(data.value);
    });
    function change_att(value){
        if(value == 0 || value == 2){
            $('.body_id').show();
            var url = '{:url("getBodys")}?att=' + value;
            $.get(url,function(data){
                $("#three_cate").empty();
                // $("#three_cate").append(new Option("请选择主体", ""));
                $.each(data.data,function(index,item){
                    if(item.id == '{$vo.body_id|default=0}'){
                        $("#three_cate").append(new Option(item.body_name, item.id, true, true));
                    }else{
                        $("#three_cate").append(new Option(item.body_name,item.id));
                    }
                });
                layui.form.render("select");
            });
        }else{
            $('.body_id').hide();
        }
        
    }
    </script>

</form>